<template>
  <div class="wrapper">
    <keep-alive :exclude="/NoCache$/">
      <!-- <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
        <router-view ref="ref" class="wrapper bg-gray" />
      </van-pull-refresh>-->
      <router-view ref="ref" class="wrapper bg-gray" />
    </keep-alive>
    <van-tabbar v-model="active" @change="handleTabChange">
      <van-tabbar-item name="fund">
        <span>计算器</span>
        <template #icon="props">
          <span class="iconfont icon-compute lg" :class="props.active ? 'active' : ''"></span>
        </template>
      </van-tabbar-item>
      <van-tabbar-item name="trend">
        <span>天气预报</span>
        <template #icon="props">
          <span class="iconfont icon-cloud lg" :class="props.active ? 'active' : ''"></span>
        </template>
      </van-tabbar-item>
      <!-- <van-tabbar-item name="me">
        <span>我的</span>
        <template #icon="props">
          <span class="iconfont icon-me lg" :class="props.active ? 'active' : ''"></span>
        </template>
      </van-tabbar-item>-->
    </van-tabbar>
  </div>
</template>

<script>
import Vue from 'vue'
import { Tabbar, TabbarItem, Icon, Button, Dialog, Field, PullRefresh } from 'vant'

Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Icon)
Vue.use(Button)
Vue.use(Field)
Vue.use(PullRefresh)

export default {
  name: "App",
  data () {
    return {
      active: '',
      // isLoading: false,
    }
  },
  mounted () {
    let name = this.$route.name
    this.active = name || 'fund'
  },
  methods: {
    handleTabChange (name) {
      this.$router.push({ name })
    },
    // async onRefresh () {
    //   this.isLoading = true
    //   if (typeof this.$refs.ref.onRefresh === 'function') {
    //     await this.$refs.ref.onRefresh()
    //     this.isLoading = false
    //   }
    // }
  }
};
</script>

<style>
@import 'assets/iconfont/iconfont.css';
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

.lg {
  font-size: 20px;
}

.wrapper {
  height: calc(100vh - 50px) !important;
}
</style>
